tinymce.PluginManager.requireLangPack("leanote_code"),tinymce.PluginManager.add("leanote_code",function(e){function t(e){var t,o=n.selection.getNode(),a=n.selection.getContent(),r=n.selection.getBookmark();if("PRE"==o.nodeName)$(o).attr("class","brush:"+e);else{if("BODY"==o.nodeName)return;try{t=$(a).text()}catch(c){}t?n.insertContent('<pre class="brush:'+e+'">'+t+"</pre>"):(t=$(o).text(),$(o).replaceWith('<pre class="brush:'+e+'">'+t+"</pre>"))}n.selection.moveToBookmark(r)}function o(){return function(){var t=this;e.on("nodeChange",function(){var o=null;try{var n=e.selection.getNode();"PRE"==n.nodeName&&(o=$.trim($(n).attr("class").split(":")[1]))}catch(a){}t.value(o)})}}var n=e;e.addButton("leanote_code",function(){var e=["CSS:css","C/C++:cpp","C#:c#","Javascript:javascript","Java:java","PHP:php","Python:python","Shell:shell","Delphi:delphi","Golang:golang","Erlang:erlang","Groovy:groovy","ActionScript:actionScript"],n=[];for(var a in e){var r=e[a].split(":");n.push({text:r[0],value:r[1]})}return{type:"listbox",text:"codeLang",tooltip:"toggleCode",values:n,fixedWidth:!0,onselect:function(e){e.control.settings.value&&t(e.control.settings.value)},onPostRender:o(n)}}),n.addCommand("toggleCode",function(){var e,t=n.selection.getNode(),o=n.selection.getContent(),a=n.selection.getBookmark();try{e=$.trim($(o).text())}catch(r){}e||(e=$.trim(o)),e?"PRE"==t.nodeName?$(t).replaceWith("<p>"+$(t).html()+"</p>"):n.insertContent("<pre>"+e+"</pre>"):$(t).replaceWith("PRE"==t.nodeName?"<p>"+$(t).html().replace(/\n/g,"<br />")+"</p>":"<pre>"+$(t).html()+"</pre>"),n.selection.moveToBookmark(a)}),n.addShortcut("ctrl+shift+c","","toggleCode"),n.addShortcut("command+shift+c","","toggleCode")});